package com.lyhlmj.oop_client.Frames.LoginAndRegister.RegisterFrame;

import com.lyhlmj.oop_client.Utils.CenterUtils;
import com.lyhlmj.oop_client.Utils.ExitUtil;
import com.lyhlmj.oop_client.Utils.GetScreenSize;

import javax.swing.*;
import java.awt.*;

public class RegisterFrame extends JFrame{
    public RegisterFrame(String title) {
        super(title);  //设置标题
        ExitUtil.exitBeforeLogin(this);

//        设置主panel
        RegisterBackgroundPanel rootPanel = new RegisterBackgroundPanel();
        rootPanel.setLayout(new FlowLayout());
        this.setContentPane(rootPanel);

//        设置注册面板panel
        RegisterPanel registerPanel = new RegisterPanel(this);
        registerPanel.setButtonFunction();
        rootPanel.add(registerPanel, BorderLayout.CENTER);
    }

    public static void initial(){
        JFrame frame = new RegisterFrame("五子棋系统——注册界面");

        //  得到Frame的大小
        int width = GetScreenSize.getFitSize()[0];
        int height = GetScreenSize.getFitSize()[1];

        frame.setSize(width, height);//设置框架的高度和宽度
        frame.setVisible(true);//设置可见性

//        设置框架显示在屏幕正中间
        CenterUtils.centerInScreen(frame);
    }
}
